//创建界面的js
var optionNum = 2;

var userOptionNum = 1;

var $cOption;

var $cMsg;

function createBuyerInit() {
	var id = $('#id').val();
	if(id){
		getContent("/buyer/find", 'id=' + id, true, function(data) {
			if (data != null) {
				$('#name').val(data.name);
				$('#code').val(data.code);
				$('#number').val(data.number);
				$('#buyerId').val(data.buyerId);
				$('#tradeUnit').val(data.tradeUnit);
			}
		});
	}
}

function saveBuyer() {

	var data = {};
	data.id = $('#id').val();
	data.name = $('#name').val();
	data.code = $('#code').val();
	data.number = $('#number').val();
	data.subprojectId = $('#subprojectId').val();
	data.buyerId = $('#buyerId').val();
	data.tradeUnit = $('#tradeUnit').val();
	if(data.subprojectId==null){
		alert('未选择关联的子项目');
		return;
	}
	var jdata = JSON.stringify(data);
	postContent("/buyer/save", jdata, true, function(data) {
		if (data != null) {
			alert('保存成功!');
		}
	});
}